#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>b[233333];
int  n;
int main(){
	int len=1;
	cin>>n;
	int k;
	cin>>k;
	b[1].push_back(k); 
	for(int i=1;i<n;i++){
		int x;
		cin>>x;
		if(x<b[len][b[len].size()-1])len++;
		b[len].push_back(x);
	}
	for(int i=1;i<=len;i++){
		for(int j=b[i].size()-1;j>=0;j--){
			cout<<b[i][j]<<" ";
		}
		cout<<"\n\n";
	}
}
